<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{lib/layui-v2.6.3/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{css/public.css}" media="all">
</head>
<body  style="margin: 0;background-color:#fff;">
<div class="layuimini-container">
    <div class="layuimini-main">

        <form class="layui-form" action="">

            <div class="layui-form-item">
                <label class="layui-form-label">登录名</label>
                <div class="layui-input-block">
                    <input type="text"  name="userName" lay-verify="title" autocomplete="off" placeholder="请输入登录名" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password"  name="userPwd" lay-verify="title" autocomplete="off" placeholder="请输入密码" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">真实姓名</label>
                <div class="layui-input-block">
                    <input type="text"  name="name" lay-verify="title" autocomplete="off" placeholder="请输入真实姓名" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" style="display: none">
                <label class="layui-form-label">父编号</label>
                <div class="layui-input-block">
                    <input type="text"  name="pId" th:value="${session.userInfo.id}" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
                    <input type="text"  name="type" th:value="2" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
                </div>
            </div>
            <!--<div class="layui-form-item" >
                <label class="layui-form-label">角色</label>
                <div class="layui-input-block">
                    <select name="roleId" lay-filter="aihao">
                        <option value="0">请选择角色</option>
                        <option
                                th:each="role:${roleList}"
                                th:value="${role.getId()}"
                                th:text="${role.getRoleName()}"
                        ></option>
                    </select>
                </div>
            </div>-->


            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>


    </div>
</div>

<script th:src="@{lib/layui-v2.6.3/layui.js}" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {

        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        var $=layui.jquery;

        var pId = [[${session.userInfo.id}]];

        //监听提交
        form.on('submit(demo1)', function (data) {
            //异步添加方法
            $.ajax({
                url:"/add_child",
                type:"post",
                data:data.field,
                success:function (res) {
                    if (res.code=="0000"){
                        //关闭当前弹出层并且刷新父级页面
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.close(iframeIndex);
                        window.parent.location.reload();
                    }else {
                        layer.msg(res.msg);
                    }
                }
            })
            return false;
        });



    });
</script>

</body>
</html>